<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>
    // if(type === "goods"){
    //     console.log("商品数据");
    // }else if(type === "user"){
    //     console.log("用户数据");
    // }else if(type === "cart"){
    //     console.log("购物车数据");
    // }

    const obj = {
        goods:function (){
            console.log("商品数据");
        },
        user:function(){
            console.log("用户数据");
        },
        cart:function(){
            console.log("购物车数据");
        }
    }
    const type = "user";
    obj[type]();
    
</script>
</html>